AbstractAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A isSuccessResponse 0 3 1
A run 0 2 1
1
import Twit from 'twit';
2
import Debug from 'debug';
3
import {BotConfig} from '..';
4
import Tweet from '../entities/Tweet';
5
6
export interface runArgs {
7
    onSuccess?: onSuccessType
8
}
9
10
type onSuccessType = (tweet: Tweet) => Promise<void>;
11
12 5
export abstract class AbstractAction {
13
    config: BotConfig;
14
    twit: Twit;
15
    debug: Debug.Debugger;
16
17
    constructor(config: BotConfig, twit: Twit, debug: Debug.Debugger) {
18 3
        this.config = config;
19 3
        this.twit = twit;
20 3
        this.debug = debug;
21
    }
22
23
    abstract run(args: runArgs): void;
24
25
    protected isSuccessResponse(response: Twit.PromiseResponse): boolean {
26 8
        return response.resp.statusCode === 200;
27
    }
28
}